import axios from "axios";

const apiClient = axios.create({
  baseURL: "http://114.66.27.8:3000", // 替换为你的实际域名
  timeout: 10000,
});

// 请求拦截器：添加 API Key
apiClient.interceptors.request.use(
  (config) => {
    const apiKey = localStorage.getItem("apiKey");
    if (apiKey) {
      config.headers["X-API-Key"] = apiKey;
      // 也可以用 query 参数：config.params = { ...config.params, api_key: apiKey }
    }
    return config;
  },
  (error) => Promise.reject(error)
);

export default apiClient;
